#include<iostream>
using namespace std;
const int N=100010;
int n=0;
int q[N],tmp[N];
typedef long long ll;
ll merge_sort(int left,int right)
{
    if(left>=right)return 0;
    int mid=(left+right)>>1;
    ll res=merge_sort(left,mid)+merge_sort(mid+1,right);
    int i=left,j=mid+1,k=0;
    while(i<=mid&&j<=right)
    {
        if(q[i]<=q[j])tmp[k++]=q[i++];
        else 
        {
            tmp[k++]=q[j++];
            res+=mid-i+1;
        } 
    }
    while(i<=mid)tmp[k++]=q[i++];
    while(j<=right)tmp[k++]=q[j++];
    for(i=left,j=0;i<=right;i++,j++)q[i]=tmp[j];
    return res;

}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>q[i];
    cout<<merge_sort(0,n-1);
    return 0;
}
